from django.http import HttpRequest, HttpResponse

p_url = 'http://127.0.0.1:8000'  # 图片请求基地址
# 开发环境图片地址
develop_url = 'http://192.168.0.157:8989'
# 图片上传地址
upload_url = "http://192.168.0.157:8989/app"


def get_server_url(request: HttpRequest) -> str:
    # 获取协议（http 或 https）
    protocol = 'https' if request.is_secure() else 'http'

    # 获取主机名和端口号
    host = request.get_host()

    # 构建完整的 URL
    server_url = f"{protocol}://{host}"

    return server_url
